<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <LINK href="resources/css/admin.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="resources/scripts/jquery-1.3.2.min.js"></script>
    <link href="../static/images/ico/favicon.png" rel="shortcut icon">
    <title>登录</title>
</head>

<c:if test="${not empty out}">
    <script>parent.location.href = "/sys/login.do";</script>
</c:if>

<body class="login_bg">
<div id="login_main">
    <div class="form">
        <form method="post" id="loginform" name="loginform" action="/sys/loginCheck.do">
            <p><label>用户名 ：</label> <input id="userName" name="userName" type="text" class="inp"/></p>

            <p><label>密码 ：</label> <input type="password" id="pwd" name="pwd" type="text" class="inp"/></p>

            <p><label>验证码 ：</label> <input name="code" type="text" class="check"/>
                <img id='mask' src="/checkCode.do" alt="点击刷新"
                     onclick="javascript:this.src='/checkCode.do?'+Math.random()"
                     style="cursor:pointer; vertical-align:middle; width:63px; height:30px; margin-left:5px;"/>
            </p>

            <p align="center"><input type="submit" value=""
                                     style="background:url(/sys/resources/images/login/login_btu.png) no-repeat; width:154px; height:41px; margin-top:12px; cursor:pointer;"
                                     onclick="login();"/></p>
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    function login() {
        var name = $("#userName").val();
        var pwd = $("#pwd").val();
        if (name == "") {
            alert("亲爱的用户，请输入帐号！");
            return;
        }
        if (pwd == "") {
            alert("亲爱的用户，请输入密码！");
            return;
        }
        loginForm.submit();
    }
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            var name = $("#userName").val();
            var pwd = $("#pwd").val();
            if (name == "") {
                alert("亲爱的用户，请输入帐号！");
                return;
            }
            if (pwd == "") {
                alert("亲爱的用户，请输入密码！");
                return;
            }
            loginForm.submit();
        }
    }
</script>
<c:if test="${not empty msg}">
    <script type="text/javascript">
        if ('${msg}' == "1") {
            location.href='/sys/index.do';
        } else if ('${msg}' == "-1") {
            alert("用户名密码错误！");
        } else if ('${msg}' == "-2") {
            alert("验证码错误！");
        }
    </script>
</c:if>
</html>
